package com.longfor.dragonshard.common.util;

import org.apache.commons.beanutils.BeanUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

/**
 * @author wangyong
 * @version v1.0
 * @create 2018-01-26 0:05
 **/
public class DTOUtils {

    /**
     * DTO转换为String
     * @param dto
     * @return
     */
    public static String toString(Object dto) {
        try {
            Map<String, String> map = BeanUtils.describe(dto);
            map.remove("class");
            return map.toString();
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            e.printStackTrace();
        }
        return null;
    }

}
